/* 
Set directory 
*/

    global root 	ENTER DIRECTORY

	global weather 	$root\Data\Weather
	
	global output 	ENTER DIRECTORY


use "$weather\weather.dta", clear


*Figure 2
twoway (hist Weightedavg_temp, lcolor(black%60) fcolor(none)) (hist Weightedavg_temp if gisstatename == "Andhra Pradesh" | gisstatename == "Telangana", color(black%20)) ///
, graphregion(color(white)) plotregion(icolor(white)) ///
legend(order (2 1)  label(2 "Andhra Pradesh") label(1 "India") ) xtitle("Daily Average Temperatures 1979-2015 (in Celsius)")
graph export "$output/F2.png", replace width(800) height(600)		


*Figure 3
preserve
bys month: egen month_temp = mean(Weightedavg_temp)
bys gdistid year month: egen month_rain_1 = sum(Weightedtot_precip)
bys month: egen month_rain = mean(month_rain_1)

bys month: keep if _n == 1 

label var month_temp "Temperature (C)"
label var month_rain "Rainfall (mm)"
label var month "Month"

gen g1 = 1 if month <3
gen g2 = 1 if month >2 & month <6
gen g3 = 1 if month >5 

twoway (connected month_temp month if g1 == 1, sort msymbol(O) yaxis(1) ylabel(10(5)30, axis(1)) lcolor(gs2) mcolor(gs2))  ///
(connected month_temp month if g2 == 1, sort msymbol(D) yaxis(1) ylabel(10(5)30, axis(1)) lcolor(gs8) mcolor(gs8))  ///
(connected month_temp month if g3 == 1, sort msymbol(T) yaxis(1) ylabel(10(5)30, axis(1)) lcolor(gs11) mcolor(gs11))  ///
(bar month_rain month if g1 == 1, sort  yaxis(2) ylabel(0(50)300, axis(2)) lcolor(gs2) color(gs2) ) ///
(bar month_rain month if g2 == 1, sort  yaxis(2) ylabel(0(50)300, axis(2)) lcolor(gs8) color(gs8) ) ///
(bar month_rain month if g3 == 1, sort  yaxis(2) ylabel(0(50)300, axis(2)) lcolor(gs11) color(none) ) ///
, graphregion(color(white)) plotregion(icolor(white)) ///
legend(order (6 5 3 2)  label(6 "GS: Rainfall") label(5 "NGS: Rainfall") label(3 "GS: Temperature") label(2 "NGS: Temperature") ) ///
xlabel(1 "Jan" 2 "Feb" 3 "Mar" 4 "Apr" 5 "May" 6 "Jun" 7 "Jul" 8 "Aug" 9 "Sep" 10 "Oct" 11 "Nov" 12 "Dec")    
graph export "$output/F3.png", replace width(800) height(600)		

restore
